﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Streambolics.Gui
{
    /// <summary>
    ///     The base class for Streambolics user controls.
    /// </summary>

    public partial class StandardUserControl : UserControl
    {
        public StandardUserControl ()
        {
            InitializeComponent ();
            AllowDragStart = true;
        }

        partial void OnThisBeginLoading (EventArgs e)
        {
            StandardForm.MainBeginUpdate ();
        }

        partial void OnThisEndLoading (EventArgs e)
        {
            StandardForm.MainEndUpdate ();
        }

        #region Drag and Drop

        protected override void OnMouseDown (MouseEventArgs e)
        {
            base.OnMouseDown (e);
            drag_MouseDown (e);
        }

        protected override void OnMouseMove (MouseEventArgs e)
        {
            base.OnMouseMove (e);
            drag_MouseMove (e);
        }

        protected override void OnMouseUp (MouseEventArgs e)
        {
            base.OnMouseUp (e);
            drag_MouseUp (e);
        }

        protected override void OnMouseLeave (EventArgs e)
        {
            base.OnMouseLeave (e);
            drag_MouseLeave (e);
        }

        protected void InterceptDragDrop (Control aContainedControl)
        {
            AllowDrop = true;
            aContainedControl.AllowDrop = true;
            aContainedControl.MouseDown += new MouseEventHandler (aContainedControl_MouseDown);
            aContainedControl.MouseUp += new MouseEventHandler (aContainedControl_MouseUp);
            aContainedControl.MouseLeave += new EventHandler (aContainedControl_MouseLeave);
            aContainedControl.MouseMove += new MouseEventHandler (aContainedControl_MouseMove);

            aContainedControl.DragEnter += new DragEventHandler (aContainedControl_DragEnter);
            aContainedControl.DragDrop += new DragEventHandler (aContainedControl_DragDrop);
        }

        void aContainedControl_MouseMove (object sender, MouseEventArgs e)
        {
            drag_MouseMove (e);
        }

        void aContainedControl_MouseLeave (object sender, EventArgs e)
        {
            drag_MouseLeave (e);
        }

        void aContainedControl_MouseUp (object sender, MouseEventArgs e)
        {
            drag_MouseUp (e);
        }

        void aContainedControl_DragDrop (object sender, DragEventArgs e)
        {
            OnDragDrop (e);
        }

        void aContainedControl_DragEnter (object sender, DragEventArgs e)
        {
            OnDragEnter (e);
        }

        void aContainedControl_MouseDown (object sender, MouseEventArgs e)
        {
            drag_MouseDown (e);
        }

        #endregion
    }
}
